/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package es.aurea.presentation.datas;

import es.aurea.transferobjects.AmountTO;
import es.aurea.transferobjects.GeneralConceptTO;
import java.math.BigDecimal;
import java.util.Date;

/**
 *
 * @author zarius
 */
public class AccountingTable {

    public static enum Type{Unknow, Concept, Value};

    public AccountingTable(AmountTO to){
        this.id = to.getId();
        this.type = Type.Value;
        this.description = to.getConceptIdDescription();
        this.name  = to.getConceptIdName();
        this.date = to.getAmountDate();
        this.value = to.getAmountValue();
        this.style = "AccountingTableChildren";
    }

    public AccountingTable(GeneralConceptTO to){
        this.id = to.getId();
        this.type = Type.Concept;
        this.description = to.getDescription();
        this.name  = to.getName();
        this.date = null;
        this.value = to.getConceptListAmount();
        this.style = "AccountingTableFather";
    }

    private Integer id;

    private String name;

    private Date date;

    private String description;

    private BigDecimal value;

    private Type type;

    private String style;

    private boolean showed=false;

    public Date getDate() {
        return date;
    }

    public String getName() {
        return name;
    }

    public Type getType() {
        return type;
    }

    public BigDecimal getValue() {
        return value;
    }

    public Integer getId() {
        return id;
    }

    public boolean getIsFather(){
        return this.getType()==Type.Concept;
    }

    public boolean getShowed() {
        return showed;
    }

    public void setShowed(boolean showed) {
        this.showed = showed;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
    public boolean equals(Object object) {
        AccountingTable  toCompare = (AccountingTable)object;
        if (toCompare.getId()==null){
            return false;
        }
        return toCompare.getType()==this.getType() && toCompare.getId().equals(this.getId());
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 37 * hash + (this.date != null ? this.date.hashCode() : 0);
        hash = 37 * hash + (this.value != null ? this.value.hashCode() : 0);
        hash = 37 * hash + this.type.hashCode();
        hash = 37 * hash + (this.showed ? 1 : 0);
        return hash;
    }

    public String getStyle() {
        return style;
    }

    public void setStyle(String style) {
        this.style = style;
    }

}
